import { fromJS } from 'immutable'
import { constants } from './index'
const defaultState = fromJS({
    topicList: [],
	articleList: [],
	authorsList: [],
	showScroll: false
});

export default (state=defaultState, action) => {
    switch(action.type) {
		case constants.GET_CHANGE_HOME:
			return state.merge({
				topicList: fromJS(action.topicList),
				articleList: fromJS(action.articleList),
				authorsList: fromJS(action.authorsList)
			});
		case constants.GET_MORE_DATA:
			return state.set('articleList', state.get('articleList').concat(action.moreList));
	    case constants.TOGGLE_SHOW_STATUS:
			return state.set('showScroll', action.showScroll);
        default:
          return state
    }
}